#encoding=utf-8

# coder : chenfeng@xyzq.com.cn
# date  : 2014-01-07

from django.shortcuts import render
from django.http import HttpResponse

class Menu:
	@staticmethod
	def index(request, category, action):
		resp = None
		if action == 'create':
			resp = Menu.create(request, category, action)
		elif action == 'update':
			resp = Menu.update(request, category, action)
		elif action == 'read':
			resp = Menu.read(request, category, action)
		elif action == 'destroy':
			resp = Menu.destroy(request, category, action)
		else:
			resp = HttpResponse()

		return resp

	@staticmethod
	def create(request, category, action):
		return HttpResponse('create action %s' % action)

	@staticmethod
	def update(request, category, action):
		return HttpResponse('update action %s' % action)

	@staticmethod
	def read(request, category, action):
		if category == 'basicsetting':
			menuTreeJSON = '''
			[
				{ name: "环境信息", model : 'AutoTestApp.view.basic.SummaryView', leaf: true },
				{ name: "全局配置", model : 'AutoTestApp.view.basic.GlobalConf', leaf: true}
			]
			'''

		elif category == 'autotest':
			menuTreeJSON = '''
			[
				{ name: "基础功能", model : 'MyDesktop.AutoTestApp.Main.Test', leaf: true },
				{ name: "案例测试", model : 'MyDesktop.AutoTestApp.Main.Test', leaf: true},
				{ name: "批量测试", model : 'MyDesktop.AutoTestApp.Main.Test', leaf: true}
			]
			'''

		elif category == 'statistics':
			menuTreeJSON = '''
			[
				{ name: "信息统计", model : 'MyDesktop.AutoTestApp.Main.Test', leaf: true }
			]
			'''
		return HttpResponse(menuTreeJSON)

	@staticmethod
	def destroy(request, category, action):
		return HttpResponse('destroy action %s' % action)
